<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    /*
        第一种:动态插入script
     */
    function loadScript(url) {
        let script = document.createElement('script')
        script.src = url
        document.body.appendChild(script)
    }

    loadScript('outter.js')

    /*
        第二种,兼容所有的浏览器的方式
     */
    function loadScriptString(code) {
        let script = document.createElement("script");
        script.type = "text/javascript";
        try {
            script.appendChild(document.createTextNode(code));
        } catch (ex) {
            script.text = code;
        }
        document.body.appendChild(script);
    }
    loadScriptString(`function sayHi() {
        console.log('hahaha')
    }`);
    // 等同于eval()吧
</script>
</body>
</html>